package ${genParam.packageName}.${genParam.moduleName}.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.Version;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import java.io.Serializable;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelTarget;
<#if hasDateField>
import java.util.Date;
</#if>
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * ${tableDesc}
 * 
 * @author gen by king
 * @email xxxx
 * @date ${.now?string["yyyy-MM-dd hh:mm:ss"]}
 */
@Data
@Accessors(chain = true)
@TableName("${dbTableName}")
@ApiModel(value = "${tableDesc}")
@Builder
@NoArgsConstructor
@AllArgsConstructor
<#if hasExportOperate>
@ExcelTarget("${classname}")
</#if>
public class ${className} implements Serializable {

	private static final long serialVersionUID = 1L;

<#list tableFields as field>
	/**
	 * ${field.desc}
	 */
<#if field.pk?? && field.pk>
	@TableId
</#if>
<#if field.name?? && field.name == "version">
    @Version
</#if>
<#if field.nullable?? && field.nullable>
<#if field.javaFieldType == 'String'>
	@NotBlank
	@Length(max=${field.length})
<#else>
	@NotNull
</#if>
</#if>
<#if field.exportable?? && field.exportable>
	@Excel(name="${field.desc}",width = 15)
</#if>
	private ${field.javaFieldType} ${field.javaFieldName};
</#list>

<#if tableType?? && tableType == 2>
	@TableField(exist = false)
	private List<${className}> children;
</#if>

	@Override
	public String toString() {
		return JSON.toJSONString(this,
			new SerializerFeature[]{
			SerializerFeature.WriteMapNullValue,
			SerializerFeature.WriteNullListAsEmpty,
			SerializerFeature.WriteNullStringAsEmpty,
			SerializerFeature.WriteNullNumberAsZero,
			SerializerFeature.WriteNullBooleanAsFalse,
			SerializerFeature.UseISO8601DateFormat}
		);
	}
}
